﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace WebToolsClslib
{
    class AuthenticateRequest
    {
        /// <summary>已经登录，不需要再次登录
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            if (HttpContext.Current.User != null)
            {
                bool isAU = HttpContext.Current.User.Identity.IsAuthenticated &&
                    (HttpContext.Current.User.Identity is FormsIdentity);
                if (isAU)
                {
                    FormsIdentity fid = ((FormsIdentity)(HttpContext.Current.User.Identity));

                    FormsAuthenticationTicket ti = fid.Ticket;
                    string userDate = ti.UserData;
                    string[] s = userDate.Split(',');

                    HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(fid, s);

                }
            }
        }
    }
}
